﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace DC2012.Render
{
    public class WallPoints
    {
        List<WallPoint> pnts = new List<WallPoint>();

        public WallPoints()
        {
            //double d1 = 29.5;
            //double d2 = 48.5;
            //double d3 = 24;

            double d1 = 18*2;
            double d2 = 20*2;
            double d3 = 12*2;
            double d4 = 10*2;
            double d5 = 6*2;
            double d6 = 3*2;

            double w1 = 64*2-2;
            double w2 = 118*2 - 2;
            double w3 = 156*2 - 2;
            double w4 = 178*2;
            double w5 = 194*2; //from mspaint


            // -1
            WallPoint wp_m1_0 = new WallPoint( -1,  0, 0,  0);
            WallPoint wp_m1_m1 = new WallPoint(-1, -1, -4,  d1);
            WallPoint wp_m1_m2 = new WallPoint(-1, -2, -8,  d1 + d2);
            WallPoint wp_m1_m3 = new WallPoint(-1, -3, 15*2,  d1 + d2 + d3);
            WallPoint wp_m1_m4 = new WallPoint(-1, -4, w4 - 92*2, d1 + d2 + d3 + d4);
            WallPoint wp_m1_m5 = new WallPoint(-1, -5, w5 - 60*2, d1 + d2 + d3 + d4 + d5);

            // 0
            WallPoint wp_0_m1 = new WallPoint(0, -1, w1, d1);
            WallPoint wp_0_m2 = new WallPoint(0, -2, w2, d1 + d2);
            WallPoint wp_0_m3 = new WallPoint(0, -3, w3, d1 + d2 + d3);
            WallPoint wp_0_m4 = new WallPoint(0, -4, w4, d1 + d2 + d3 + d4);
            WallPoint wp_0_m5 = new WallPoint(0, -5, w5, d1 + d2 + d3 + d4 + d5);

            //WallPoint wp_m2_m4 = new WallPoint(-2, -4, 0, d1 + d2 + d3 + d4);

            // (-2)
            WallPoint wp_m2_m2 = new WallPoint(-2,-2, 0, d1 + d2 + d3);
            WallPoint wp_m2_m3 = new WallPoint(-2, -3, 0, d1 + d2 + d3);
            WallPoint wp_m2_m4 = new WallPoint(-2, -4, 0, d1 + d2 + d3 + d4);
            WallPoint wp_m2_m5 = new WallPoint(-2, -5, w5-60*2-60*2, d1 + d2 + d3 + d4 + d5);

            // (-3)
            WallPoint wp_m3_m4 = new WallPoint(-3, -4, 0, d1 + d2 + d3 + d4);
            WallPoint wp_m3_m5 = new WallPoint(-3, -5, w5 - 60 * 2 - 60 * 2 - 60 * 2, d1 + d2 + d3 + d4 + d5 + d6);

            pnts.Add(wp_m1_0);
            pnts.Add(wp_m1_m1);
            pnts.Add(wp_m1_m2);
            pnts.Add(wp_m1_m3);
            pnts.Add(wp_m1_m4);
            pnts.Add(wp_m1_m5);


            pnts.Add(wp_0_m1);
            pnts.Add(wp_0_m2);
            pnts.Add(wp_0_m3);
            pnts.Add(wp_0_m4);
            pnts.Add(wp_0_m5);


            pnts.Add(wp_m2_m2);
            pnts.Add(wp_m2_m3);
            pnts.Add(wp_m2_m4);
            pnts.Add(wp_m2_m5);

            pnts.Add(wp_m3_m4);
            pnts.Add(wp_m3_m5);

        }

        public WallPoint this[int X, int Y]
        {
            get
            {
                var x = (from i in pnts
                         where i.Side == X && i.Depth == Y
                         select i).FirstOrDefault();

                return x;
            }
            
        }
    }

    public class WallPoint
    {
        /// <summary>
        /// Relative coordinate - look in front of me
        /// Im standing on 0 and further i look small number i get....three steps away = -3
        /// </summary>
        public int Depth { get; set; }

        /// <summary>
        /// Relative coordinate - 
        /// Left is smaller than 0,
        /// center is 0,
        /// Right is higher than 0 
        /// </summary>
        public int Side { get; set; }

        /// <summary>
        /// X and Y of texture coordinate
        /// </summary>
        public Vector2 Wall { get; set; }

        ///// <summary>
        ///// Top center coordinate for wall item. Item must tell how hight it is. That will be added to Y coordinate
        ///// </summary>
        //public Vector2 WallItemCenter { get; set; }

        /// <summary>
        /// Quick contructor
        /// </summary>
        /// <param name="side">Relative coordinate - Left is smaller than 0, center is 0, Right is higher than 0</param>
        /// <param name="depth">Relative coordinate - look in front of me. Im standing on 0 and further i look small number i get....three steps away = -3</param>
        /// <param name="X">Wall coord</param>
        /// <param name="Y">Wall coord</param>
        /// <param name="wiX">WallItem center X</param>
        /// <param name="wiY">WallItem center Y</param>
        public WallPoint(int side, int depth, double X, double Y)
        {
            Side = side;
            Depth = depth;
            Wall = new Vector2((int)X,(int)Y);
            //WallItemCenter = new Vector2((int)wiX, (int)wiY);
        }

    }


}
